/**
 * Created by Administrator on 2017/3/4.
 */
import { Injectable } from '@angular/core';
import 'rxjs/add/operator/map';
import { Jsonp, URLSearchParams,Response } from '@angular/http';
import { Observable }   from 'rxjs/observable';
import 'rxjs/add/operator/catch';

@Injectable()
export class DonatwoService {
  constructor(private jsonp: Jsonp) {}
  public statu='';
  private showfrom:boolean;
  cardinfro (firstname:string, lastname:string,email:string,phone:string,zipcode:string,address:string,city:string,state:string,country:string,cardnum:string,cvv2:string,
     month:string,year:string,cardname:string,money:string,type:string
  ) {
    let wikiUrl = 'http://api.pinwu.net/pay/onlinepay';
    let params = new URLSearchParams();
    params.set('firstname', firstname);                 // the user's repwd
    params.set('lastname', lastname);             // the user's email
    params.set('email', email);     // the user's name
    params.set('phone', phone);
    params.set('zipcode', zipcode);
    params.set('address', address);
    params.set('city', city);
    params.set('state', state);
    params.set('country', country);
    params.set('cardnum', cardnum);
    params.set('cvv2', cvv2);
    params.set('month', month);
    params.set('year', year);
    params.set('cardname', cardname);
    params.set('money', money);
    params.set('type', type);
    params.set('callback', 'JSONP_CALLBACK');

    return this.jsonp
      .get(wikiUrl, { search: params })
      .map((res:Response)=>{
        let result=res.json();
        console.log(result);
        return result;
      });
  }
}
